using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using CodRevit.ViewModels;
using CodRevit.Views;

namespace CodRevit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class DeleteFilterCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var window = new DeleteFilterView();
            var viewModel = new DeleteFilterViewModel(commandData.Application, window);
            window.DataContext = viewModel;

            // 设置窗口位置
            IntPtr revitHandle = Autodesk.Windows.ComponentManager.ApplicationWindow;
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.Owner = System.Windows.Interop.HwndSource.FromHwnd(revitHandle).RootVisual as System.Windows.Window;

            window.ShowDialog();
            return Result.Succeeded;
        }
    }
}